package br.festasconquista;
import java.util.ArrayList;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class FestaAdapter_frag_festas extends BaseAdapter {

	private Context context;
	private ArrayList<Festa_objeto> lista;
	
	public FestaAdapter_frag_festas(Context context, ArrayList<Festa_objeto> lista2){
		this.context = context;
		this.lista = lista2;
	}
	
	
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return lista.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return lista.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		
		View layout;
		Festa_objeto festa = lista.get(position);
		
		if(convertView == null){
			LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			layout = inflater.inflate(R.layout.festa_custom_data, null);
		}else{
			layout = convertView;
		}
		
		TextView tv_nome = (TextView) layout.findViewById(R.id.tela1_tvFestaNome);
		tv_nome.setText(festa.getNome()); 
		
		TextView tv_hora = (TextView) layout.findViewById(R.id.tela1_tvFestaHora);
		tv_hora.setText(festa.getHora());
		
		TextView tv_data = (TextView) layout.findViewById(R.id.tela1_tvDataEvento);
		tv_data.setText(festa.getData());
		

		return layout;
		
	}

}
